using System.Collections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using Ezio.Model;

//Service Route: Copy to 'Global.asax'
//  RouteTable.Routes.Add(new ServiceRoute("ProgramacionMenus", new WebServiceHostFactory(), typeof(ProgramacionMenusService)));
//
namespace Ezio.Service
{
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    [XmlSerializerFormat]
    public class ProgramacionMenusService : BaseService
    {

        [WebInvoke(UriTemplate = "", Method = "POST")]
        public bool Create(ProgramacionMenus ProgramacionMenu)
        {
            Provider.AddToProgramacionMenus(ProgramacionMenu);
            return Provider.TrySaveChanges();
        }

        [WebInvoke(UriTemplate = "CreateMassive", Method = "POST")]
        public bool Create(ArrayList ListProgramacionMenu)
        {
            ListProgramacionMenu.ToArray().ToList().ForEach(t => Provider.AddToProgramacionMenus((ProgramacionMenus)t));
            return Provider.TrySaveChanges();
        }

        [WebInvoke(UriTemplate = "", Method = "GET")]
        public ArrayList GetAll()
        {
            return new ArrayList(Provider.ProgramacionMenus.ToList());
        }

        [WebInvoke(UriTemplate = "{Id}", Method = "GET")]
        public ProgramacionMenus GetById(string Id)
        {
            return Provider.ProgramacionMenus.First(i => i.IdProgramacionMenu == int.Parse(Id));
        }

        [WebInvoke(UriTemplate = "", Method = "PUT")]
        public bool Update(ProgramacionMenus ProgramacionMenu)
        {
            ProgramacionMenus miProgramacionMenu = Provider.ProgramacionMenus.Where(t => t.IdProgramacionMenu == ProgramacionMenu.IdProgramacionMenu).First();
            miProgramacionMenu.Copy(ProgramacionMenu);
            return Provider.TrySaveChanges();
        }

        [WebInvoke(UriTemplate = "{IdColegio}", Method = "POST")]
        public ArrayList GetByColegio(string IdColegio)
        {
            return new ArrayList(Provider.ProgramacionMenus.Where(p => p.IdColegio == int.Parse(IdColegio)).ToList());
        }
    }
}